﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using Castle.Services.Transaction;
using Castle.Facilities.IBatisNetIntegration;

using Meqs.Entity;
using Meqs.Logic.Interface;

namespace Meqs.Logic.Implement
{
    [Transactional]
    public class SecuritySettingLogic : CommonLogic<SecuritySetting, int>, ISecuritySettingLogic
    {

        /// <sammury>
        /// 创建对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(SecuritySetting entity)
        {
            return CreateObject(entity);

        }

        /// <sammury>
        /// 更新对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(SecuritySetting entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public SecuritySetting FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<SecuritySetting> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<SecuritySetting> FindAll(Hashtable table)
        {
            return FindObject(table);
        }
        public int GetOperatorSecurityValue(Hashtable ht)
        {
            try
            {
                string statementName = "SecuritySetting.GetOperatorSecurityValue";
                return ExecuteQueryForObject<int>(statementName, ht);
            }
            catch (Exception ex)
            {

                throw;
            }
            return 0;
        }

        public int GetViewSecurityValue(Hashtable ht)
        {
            try
            {
                string statementName = "SecuritySetting.GetViewSecurityValue";
                return ExecuteQueryForObject<int>(statementName, ht);
            }
            catch (Exception ex)
            {

                throw;
            }
            return 0;
        }

        public IList<TeacherRoles> FindTeacherRoles(Hashtable ht)
        {
            try
            {
                string statementName = "SecuritySetting.FindTeacherRoles";
                return ExecuteQueryForList<TeacherRoles>(statementName, ht);
            }
            catch (Exception ex)
            {

                throw;
            }
        }
        public IList<ClsInfo> FindClsinfo(Hashtable ht)
        {
            try
            {
                string statementName = "SecuritySetting.FindClsinfo";
                return ExecuteQueryForList<ClsInfo>(statementName, ht);
            }
            catch (Exception ex)
            {

                throw;
            }
        }

        public IList<TeachClsCause> FindTeachClsCause(Hashtable ht)
        {
            try
            {
                string statementName = "SecuritySetting.FindTeachClsCause";
                return ExecuteQueryForList<TeachClsCause>(statementName, ht);
            }
            catch (Exception ex)
            {

                throw;
            }
        }

        /// <summary>
        /// 获取用户拥有的权限
        /// </summary>
        /// <param name="schoolMark"></param>
        /// <param name="schoolYear"></param>
        /// <param name="term"></param>
        /// <param name="teacherId"></param>
        /// <param name="securityId"></param>
        /// <returns></returns>
        public IList<SecuritySetting> GetUserSecurityValue(string schoolMark, int schoolYear, int term, int teacherId, int securityId)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark",schoolMark);
            ht.Add("SchoolYear",schoolYear);
            ht.Add("Term",term);
            ht.Add("TeacherID",teacherId);
            ht.Add("SecurityID",securityId);

            try
            {
                return FindCustomer<SecuritySetting>("SecuritySetting.GetUserSecurityValue", ht);
            }
            catch (Exception)
            {
                
                throw;
            }
        }
    }
}